Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

fix: warn on legacy Bedrock cache options#1055

Open
asim48-ctrl wants to merge 1 commit into
strands-agents:mainfrom
asim48-ctrl:asim/bedrock-legacy-cache-warning
Open

fix: warn on legacy Bedrock cache options#1055
asim48-ctrl wants to merge 1 commit into
strands-agents:mainfrom
asim48-ctrl:asim/bedrock-legacy-cache-warning

Conversation

@asim48-ctrl

Copy link
Copy Markdown

Summary

This adds a small runtime warning when BedrockModel receives the stale cachePrompt or cacheTools fields documented on the older indexed API page. Those fields are not honored by the current provider, so the warning points users to cacheConfig instead of silently leaving Bedrock prompt caching disabled.

Fixes #1027.

Testing

  • npm ci --ignore-scripts
  • npm run test -w strands-ts -- src/models/tests/bedrock.test.ts -t "legacy cache"
  • npx prettier --check strands-ts/src/models/bedrock.ts strands-ts/src/models/tests/bedrock.test.ts
  • git diff --check

@asim48-ctrl asim48-ctrl temporarily deployed to manual-approval May 13, 2026 02:17 — with GitHub Actions Inactive
@asim48-ctrl asim48-ctrl temporarily deployed to manual-approval May 13, 2026 02:17 — with GitHub Actions Inactive
@github-actions github-actions Bot added the strands-running <strands-managed> Whether or not an agent is currently running label May 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Assessment: Approve

Clean, minimal fix that addresses the issue well. The warning message follows the project's logging style guide, warnOnce is appropriate to avoid log flooding, and the type cast approach is a reasonable way to detect fields that aren't part of the typed interface.

Minor suggestion
  • Testing: The test only exercises the path where both cachePrompt and cacheTools are present simultaneously. Consider adding a case where only one is provided (e.g., just cachePrompt) to confirm the || logic triggers for each field independently. This is low-risk given the simplicity of the conditional, so not blocking.

@github-actions github-actions Bot removed the strands-running <strands-managed> Whether or not an agent is currently running label May 22, 2026
if (legacyCacheOptions?.cachePrompt !== undefined || legacyCacheOptions?.cacheTools !== undefined) {
warnOnce(
logger,
'unsupported_fields=<cachePrompt,cacheTools> | cachePrompt and cacheTools are not supported by BedrockModel, use cacheConfig instead'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. (Functional gap) updateConfig is not covered. The same legacy fields can
  land via updateConfig({ cachePrompt: 'default' } as any) (bedrock.ts:513) —
  that path silently drops them just like the constructor used to. If the goal
  is "users shouldn't believe caching is enabled when it isn't," updateConfig
  should warn too. Minor refactor: extract a warnIfLegacyCacheOptions(options)
  helper and call it in both places.

  2. (Test placement) The new test lives in the wrong describe block. Per the
  diff context (@@ -448,6 +448,18 @@), the it('warns when unsupported legacy
  cache options...') is inserted at the tail of describe('getConfig')
  (bedrock.test.ts:437), not describe('constructor') (line 183), where the
  analogous it('warns when modelId is not explicitly set') test already lives
  (line 190). Move it next to the other constructor-warning tests for
  discoverability.

  3. (Message accuracy) Warning text claims both fields when only one may be
  present. If a caller passes only cachePrompt, the warning still says
  unsupported_fields=<cachePrompt,cacheTools>. Either:
  - List only the keys actually present (more accurate, costs warnOnce dedup
  since the key set varies), or
  - Keep the static message but drop the redundancy (the structured prefix and
  prose say the same thing twice).

@strands-agent

Copy link
Copy Markdown
Collaborator

This repository has been merged into the strands-agents/harness-sdk monorepo and will be archived shortly. All new development happens there.

If this PR is still relevant, please recreate it against the monorepo. The code now lives under strands-ts/. Full commit history was preserved, so your base should be findable.

Apologies for the disruption, and thank you for contributing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Stale BedrockModelOptions docs list cachePrompt/cacheTools, but v1.0.0 only honors cacheConfig

4 participants